package org.example.service.impl;

import org.example.domain.UserRole;
import org.example.mapper.UserMapper;
import org.example.mapper.UserRoleMapper;
import org.example.service.UserRoleService;
import org.example.vo.CapacityVo;
import org.example.vo.DriverVo;
import org.example.vo.MaterialVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 14168
 * @description 针对表【sys_user_role】的数据库操作Service实现
 * @createDate 2024-05-22 19:07:25
 */
@Service
public class UserRoleServiceImpl implements UserRoleService {

    @Autowired
    private UserRoleMapper userRoleMapper;
    @Autowired
    private UserMapper userMapper;


    public void add(UserRole userRole) {
        userRoleMapper.add(userRole);
    }

    public List<DriverVo> listAll() {
        List<DriverVo> userRoles = userRoleMapper.listAll();
        System.err.println(userRoles);
        return userRoles;
    }


    public void delete(Integer id) {
        userMapper.deleteUser(id);
        userRoleMapper.deleteUser(id);
    }

    /**
     * 查询用户所属角色
     *
     * @param username
     * @return
     */
    public Integer queryUser(String username) {

        return userRoleMapper.queryUser(username);
    }

    public String queryRoleByUserId(String id) {
        return userRoleMapper.queryRoleByUserId(id);
    }


    public List<CapacityVo> getCapacity() {
        return userMapper.getCapacity();
    }


    public List<MaterialVo> getMaterial() {
        return userMapper.getMaterial();
    }
}




